<template>
  <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" append-to-body v-dialogDrag width="90%">
    <div class="shadow" style="">

      <div class="flex flex-between" style="margin-bottom: 10px;">
        <el-descriptions class="margin-top " :contentStyle="CS" :label-style="LS" title="" :column="3" size="medium"
                         border>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-c-scale-to-original"></i>
              到货单号
            </template>
            {{ daohuo.lvDaohuo.nos }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-time"></i>
              到货时间
            </template>
            {{ daohuo.lvDaohuo.arrivalDate }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-money"></i>
              产品名称
            </template>
            {{ daohuo.goodsSalebuyall.goodsName }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-money"></i>
              产品型号
            </template>
            {{ daohuo.goodsSalebuyall.goodModel }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-money"></i>
              存货编码
            </template>
            {{ daohuo.goodsSalebuyall.goodsCode }}
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-user"></i>
              到货数量
            </template>
            {{ daohuo.daohuoCount }}
          </el-descriptions-item>
        </el-descriptions>
      </div>


      <div style="margin-bottom: 10px;">
        <el-button size="mini" icon="el-icon-warning" :plain="true" v-show="!testIsSample"
                   @click="onButtonTestType('material_main')">材料材质
        </el-button>
        <el-button size="mini" icon="el-icon-warning" :plain="testType === 'sample'" v-show="!testIsSample"
                   @click="onButtonTestType('material_assist')">材料辅材
        </el-button>
        <!--        <el-button size="mini" icon="el-icon-warning" :plain="true"-->
        <!--                   @click="onButtonTestType('process')">生产过程</el-button>-->

        <el-button size="mini" icon="el-icon-warning" :plain="testType === 'surface'" v-show="!testIsSample"
                   @click="onButtonTestType('surface')">外观检查
        </el-button>
        <el-button size="mini" icon="el-icon-warning" :plain="testType === 'size'" v-show="!testIsSample"
                   @click="onButtonTestType('size')">尺寸检查
        </el-button>
        <el-button size="mini" icon="el-icon-warning" :plain="testType === 'zn'" v-show="!testIsSample"
                   @click="onButtonTestType('zn')">镀锌质量
        </el-button>

        <!-- (防振锤)-->
        <el-button size="mini" icon="el-icon-warning" :plain="testType === 'machineryHammer'" v-if="goodsName.includes('防振锤')" v-show="!testIsSample"
                   @click="onButtonTestType('machineryHammer')">机械试验(防振锤)
        </el-button>

        <el-button size="mini" v-if="typeName==='悬垂线夹' || typeName==='联结金具'" icon="el-icon-warning" v-show="!testIsSample"
                   :plain="testType === 'machineryLink'"
                   @click="onButtonTestType('machineryLink')">机械试验
          <!-- (悬垂线夹和连接金具)-->
        </el-button>
        <el-button size="mini" v-if="goodsName.includes('间隔棒')" icon="el-icon-warning" v-show="!testIsSample"
                   :plain="testType === 'machineryStick'"
                   @click="onButtonTestType('machineryStick')">机械试验
          <!-- (间隔棒)-->
        </el-button>
        <el-button size="mini" icon="el-icon-warning" :plain="testType === 'sample'" v-show="testIsSample"
                   @click="onButtonTestType('sample')">抽样检查
        </el-button>
      </div>

      <factory-material-main-list v-if="testType==='material_main'" :materialId="materialId" :goodsSaleId="goodsSaleId"
                                  :workOrderId="workOrderId" :editFlag="editFlag"
                                  :goodsId="goodsId" :daohuoDetailId="daohuoDetailId"></factory-material-main-list>

      <factory-material-assist-list v-if="testType==='material_assist'" :materialId="materialId"
                                    :goodsSaleId="goodsSaleId" :workOrderId="workOrderId" :editFlag="editFlag"
                                    :goodsId="goodsId" :daohuoDetailId="daohuoDetailId"></factory-material-assist-list>
      <factory-product-process-list v-if="testType==='process'" :workOrder="workOrder" :workOrderId="workOrderId"
                                    :goodsId="goodsId" :editFlag="editFlag"
                                    :daohuoDetailId="daohuoDetailId"
                                    :rukuId="rukuId"></factory-product-process-list>
      <factory-goods-test-surface-list v-if="testType==='surface'" :workOrderId="workOrderId" :goodsId="goodsId"
                                       :daohuoDetailId="daohuoDetailId" :editFlag="editFlag"
                                       :rukuId="rukuId"></factory-goods-test-surface-list>
      <factory-goods-test-size-list v-if="testType==='size'" :workOrderId="workOrderId" :goodsId="goodsId"
                                    :daohuoDetailId="daohuoDetailId" :editFlag="editFlag"
                                    :rukuId="rukuId"></factory-goods-test-size-list>
      <factory-goods-test-zn-list v-if="testType==='zn'" :workOrderId="workOrderId" :goodsId="goodsId"
                                  :daohuoDetailId="daohuoDetailId" :editFlag="editFlag"
                                  :rukuId="rukuId"></factory-goods-test-zn-list>

      <factory-goods-test-machinery-common-list v-if="testType==='machineryCommon'" :workOrderId="workOrderId"
                                                :daohuoDetailId="daohuoDetailId"
                                                :goodsId="goodsId" :editFlag="editFlag"
                                                :rukuId="rukuId"></factory-goods-test-machinery-common-list>

      <factory-goods-test-machinery-hammer-list v-if="testType==='machineryHammer'" :workOrderId="workOrderId"
                                                :daohuoDetailId="daohuoDetailId"
                                                :goodsId="goodsId" :editFlag="editFlag"
                                                :rukuId="rukuId"></factory-goods-test-machinery-hammer-list>
      <factory-goods-test-machinery-link-list v-if="testType==='machineryLink'" :workOrderId="workOrderId"
                                              :goodsId="goodsId" :daohuoDetailId="daohuoDetailId" :editFlag="editFlag"
                                              :rukuId="rukuId"></factory-goods-test-machinery-link-list>
      <factory-goods-test-machinery-stick-list v-if="testType==='machineryStick'" :workOrderId="workOrderId"
                                               :daohuoDetailId="daohuoDetailId"
                                               :goodsId="goodsId" :editFlag="editFlag"
                                               :rukuId="rukuId"></factory-goods-test-machinery-stick-list>
      <factory-goods-product-store-list v-if="testType==='store'" :workOrderId="workOrderId" :goodsId="goodsId"
                                        :daohuoDetailId="daohuoDetailId" :editFlag="editFlag"
                                        :rukuId="rukuId"></factory-goods-product-store-list>

      <factory-goods-test-sample-list v-if="testType==='sample'" :workOrderId="workOrderId" :goodsId="goodsId"
                                      :daohuoDetailId="daohuoDetailId" :daohuo="daohuo"  :editFlag="editFlag"
                                      :rukuId="rukuId"></factory-goods-test-sample-list>
    </div>
  </el-dialog>
</template>

<script>
import {deleteAction, getAction, getById} from '@/api/manage'
import FactoryTestZnForm from '@/views/develop/factory/factoryTestZn/module/FactoryTestZnForm'
import FactoryMaterialAssistList from "@/views/develop/factory/factoryMaterialAssist/FactoryMaterialAssistList.vue";
import FactoryProductProcessList from "@/views/develop/factory/factoryProductProcess/FactoryProductProcessList.vue";
import FactoryGoodsTestSizeList from "@/views/develop/factory/factoryTestSize/FactoryGoodsTestSizeList.vue";
import FactoryGoodsTestZnList from "@/views/develop/factory/factoryTestZn/FactoryGoodsTestZnList.vue";
import FactoryGoodsTestMachineryHammerList
  from "@/views/develop/factory/factoryTestMachineryHammer/FactoryGoodsTestMachineryHammerList.vue";
import FactoryGoodsTestMachineryLinkList
  from "@/views/develop/factory/factoryTestMachineryLink/FactoryGoodsTestMachineryLinkList.vue";
import FactoryGoodsTestMachineryStickList
  from "@/views/develop/factory/factoryTestMachineryStick/FactoryGoodsTestMachineryStickList.vue";
import FactoryGoodsTestSurfaceList from "@/views/develop/factory/factoryTestSurface/FactoryGoodsTestSurfaceList.vue";
import FactoryGoodsProductStoreList from "@/views/develop/factory/factoryProductStore/FactoryGoodsProductStoreList.vue";
import FileUploadShow from "@/components/FileUpload/FileUploadShow.vue";
import FactoryGoodsTestSampleList from "@/views/develop/factory/factoryTestSample/FactoryGoodsTestSampleList.vue";
import FactoryGoodsTestMachineryCommonList
  from "@/views/develop/factory/factoryTestMachineryCommon/FactoryGoodsTestMachineryCommonList.vue";
import FactoryMaterialMainList from "@/views/develop/factory/factoryMaterialMain/FactoryMaterialMainList.vue";


export default {
  name: "FactoryTestQualityDaohuo",
  components: {
    FactoryMaterialMainList,
    FactoryGoodsTestMachineryCommonList,
    FileUploadShow,
    FactoryGoodsProductStoreList,
    FactoryGoodsTestSurfaceList,
    FactoryGoodsTestMachineryStickList,
    FactoryGoodsTestMachineryLinkList,
    FactoryGoodsTestMachineryHammerList,
    FactoryGoodsTestZnList,
    FactoryGoodsTestSizeList,
    FactoryGoodsTestSampleList,
    FactoryProductProcessList,
    FactoryMaterialAssistList,
    FactoryTestZnForm,
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      activeName: "first",
      // 弹出层标题
      title: "到货质量检验",
      // 是否显示弹出层
      open: false,
      // 显示搜索条件
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 出厂试验-镀锌质量表格数据
      dataList: [],

      CS: {
        'text-align': 'center',  //文本居中
        'min-width': '250px',   //最小宽度
        'word-break': 'break-all'  //过长时自动换行
      },
      LS: {
        'color': '#000',
        'text-align': 'center',
        'font-weight': '600',
        'height': '40px',
        'min-width': '110px',
        'word-break': 'keep-all'
      },
      daohuo: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        projectId: null,
        orderId: null,
        goodsId: null,
        goodsName: null,
        goodsModel: null,
        batchNumber: null,
        productNumber: null,
        inspectTime: null,
        znThick: null,
      },
      url: {
        list: '/factoryTestZn/factoryTestZn/list',
        remove: '/factoryTestZn/factoryTestZn/',
        export: '/factoryTestZn/factoryTestZn/export',
        getMaterialById: '/factoryTestMaterial/factoryTestMaterial/',
      },
      tableMaxHeight: window.innerHeight - 320,
      isButton: 1,
      list: ['原材料、组部件检测', '生产工艺及过程检测', '出厂试验', '成品入库'],
      isIndex: 0,
      total1: 0,
      loading1: true,
      activeName1: '1',
      dataList1: [],
      testType: 'material_main',
      workOrderId: null,
      workOrder: {},
      workOrderCode: null,
      goodsId: null,
      goodsSaleId: null,
      daohuoDetailId: null,
      rukuId: null,
      materialId: null,
      typeName: null,
      goodsName: null,
      editFlag: false,
      testIsSample:false, //是否取样
    };
  },
  created() {
    this.getList();
    window.addEventListener('resize', this.getTableHeight);
  },
  destroyed() {
    window.removeEventListener('resize', this.getTableHeight)
  },
  methods: {
    /** 查询出厂试验-镀锌质量列表 */
    getList() {
      this.loading = true;
      getAction(this.url.list, this.queryParams).then(response => {
        this.dataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getTableHeight() {
      this.tableHeight = window.innerHeight - 320
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    // 入库质检
    showByRukuDetail(ruku) {
      this.rukuId = ruku.id;
      this.goodsSaleId = ruku.goodsSaleId;
      this.goodsId = ruku.goodsId;
      this.materialId = ruku.params.materialMain;
      this.daohuoDetailId = ruku.daohuodetailId;
      this.open = true;
    },

    // 到货质检
    showByDaohuoDetail(daohuo,editFlag) {
      this.editFlag = editFlag;
      this.daohuo = daohuo;

      if(daohuo.daohuoCount<=100){
        this.testIsSample = false;
        this.testType= 'material_main';
      }else{
        this.testIsSample = true;
        this.testType= 'sample';
      }

      this.typeName = daohuo.goods.deptName;
      this.goodsName = daohuo.goods.name;
      this.daohuoDetailId = daohuo.id;
      let materialId = daohuo.goods.materialMain;
      getById(this.url.getMaterialById, materialId).then(response => {
        this.material = response.data;
        this.materialType = response.data.type;
        this.materialId = response.data.id;
      });

      this.goodsSaleId = daohuo.goodsSaleId;
      this.goodsId = daohuo.goodId;
      this.open = true;
    },


    // 领料查看质检
    showByLingLiaoDetail(lingliao) {
      this.rukuId = lingliao.rukuId;
      this.goodsSaleId = lingliao.gsaleId;
      this.goodsId = lingliao.goodsId;
      this.materialId = lingliao.params.materialMainId;
      this.daohuoDetailId = lingliao.params.daohuodetailId;
      this.open = true;
    },


    onIndex(e) {
      this.isIndex = e
    },
    onButtonTestType(type) {
      this.testType = type;
    },

    onButtons(e) {
      this.isButton = e;
    },

  }
};
</script>
<style scoped lang="scss">
.shadow {
  box-shadow: 2px 4px 7px rgba(0, 0, 0, 0.05);
}

.li1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 25%;
  margin: 0 5px;
  padding: 0px 10px;
  box-shadow: 2px 4px 7px rgba(0, 0, 0, 0.05);
  border: 1px solid #EBEEF5;
  background: #fff;
  border-radius: 5px;
  color: #333;
  transition: all .5s;
}

.li2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 25%;
  margin: 0 5px;
  padding: 0px 20px;
  box-shadow: 2px 4px 7px rgba(0, 0, 0, 0.05);
  border: 1px solid #1890ff;
  background: #e8f4ff;
  border-radius: 5px;
  color: #1890ff;
  transition: all .5s;
}

.hcss {
  font-size: 42px;
  font-weight: 700;
  background: -webkit-linear-gradient(#C0C4CC, transparent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.hcss1 {
  font-size: 42px;
  font-weight: 700;
  background: -webkit-linear-gradient(#409EFF, transparent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

::v-deep .el-collapse-item__wrap,
::v-deep .el-collapse,
::v-deep .el-collapse-item__header {
  border: none;
}

::v-deep .el-collapse-item__content {
  padding-bottom: 0;
}

.hbox {
  display: flex;
  align-items: center;
}

.hboxhcss {
  font-size: 16px;
  color: #333;
  font-weight: 600;
}

.hboxxian {
  width: 5px;
  height: 18px;
  background: #1890ff;
  margin-right: 5px;
  border-radius: 2px;
}
</style>
